Basic Polymorphic Typechecking

نویسنده

  • Luca Cardelli
چکیده

Introduction Polymorphic means to have many forms. As related to programming languages, it refers to data or programs which have many types, or which operate on many types. There are several arbitrary ways in which programs can have many types; we are mostly interested in a particularly orderly form of polymorphism called parametric polymorphism. This is a property of programs which are parametric with respect to the type of some of their identifiers. There are two major ways of achieving parametric polymorphism which are conceptually related but pragmatically very different: explicit and implicit polymorphism. Parametric polymorphism is called explicit when parametrization is obtained by explicit type parameters in procedure headings, and corresponding explicit applications of type arguments when procedures are called. In this case, parametric polymorphism reduces to the notion of having parameters of type type (without necessarily adopting the notion that type has itself type type). Here is a definition of the polymorphic identity with explicit type parameters (where fun stands for λ-abstraction) and its application to an integer and a boolean:

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Performance polymorphism

In an interactive functional programming environment with a Milner-style polymorphic type system (Milner 1978), a modification to one definition may imply changes in the types of other definitions. A polymorphic typechecker must carry out some re-typechecking to determine all of these changes. This paper presents a new typechecking algorithm which performs fine-grained re-typechecking based on ...

متن کامل

A visualisation of polymorphic type checking

The understanding of polymorphic typechecking and type errors is poorly supported by contemporary functional language implementations. Here, a novel visualisation of functions and their types is presented based on the generation of function speciic icons with graphical type representations which change dynamically as functions are applied. This visualisation has been implemented for a Standard ...

متن کامل

Type inference for polymorphic methods in Java-like languages

In mainstream class-based object-oriented languages with nominal types, like C++, Java and C#, typechecking algorithms require methods to be annotated with their parameter types, which are either fixed or constrained by a (nominal) bound. On the contrary, languages like ML, CaML and Haskell use powerful type inference algorithms capable of calculating the type for a function in which parameter ...

متن کامل

Bidirectional polymorphism through greed and unions

Bidirectional typechecking has become popular in advanced type systems because it works in many situations where inference is undecidable. In this paper, I show how to cleanly handle parametric polymorphism in a bidirectional setting, even in the presence of subtyping. The first contribution is a bidirectional type system that supports first-class (higher-rank and impredicative) polymorphism bu...

متن کامل

On Typechecking B

The typechecking system of the formal method B is discussed. An inconsistency in the public definition of the B method, attributable to a flaw in the typechecking system, is uncovered: the typechecking method expects the types of variables to be given in one membership predicate, such as a, b, c ∈ A × B × C, instead of with several membership predicates joined by conjunction, like a ∈ A∧b ∈ B∧c...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:
  • Sci. Comput. Program.

دوره 8  شماره 

صفحات  -

تاریخ انتشار 1987